library Wave18c initializer init requires LegacySystem, EndCinematics


    private function EnableMOSSelection takes nothing returns nothing
        local integer i = 1
        local integer i3
        if udg_DMDeliveryTime[101]<1337.0 then
            set udg_DMDeliveryTime[101] = 1337.0
            //call EnableTrigger(gg_trg_ShowStats)
            call PolledWait(5.)
            set i3=1
            loop
                exitwhen i3>udg_InitialPlayers
                
                set i3=i3+1
            endloop
        endif
    endfunction

    private function Wave18c takes nothing returns nothing
        local integer i
        local integer xp
        set udg_CurrentWave = 18
        call GenericActions.execute()
        call PolledWait(60.)
        call RandomSpawn('n00M',5,udg_Spawn) //Fast Zombies
        call GeneralText(10.0, "|cffcd950cMarine |r : We don't have much time left." )
        call PolledWait(80.*udg_Pace)
        call SetPopperExplosionControlEnabled(false)
		
		call ExecuteRegisteredFunction("Wave15c.cleanup")
		
        if udg_Players>0 and (getBoolean(null,"NukeSuccess") == true) then
            call GeneralText(10.0, "|cffcd950cCWO Nadav|r : Do you think it's dead?" )
            call PolledWait(10.)
            set udg_SectorClear=true
			call SetMOSEnabled(true)

            if (udg_Mode==1 or udg_Mode==4) and udg_Players>0 then
                call ALICE2Text(10.0, "Evacuation Complete. |cff1e90ff200 XP|r awarded to all Marines." )
                set i=1
                loop
                    exitwhen i>udg_InitialPlayers
                    if GetPlayerSlotState(ConvertedPlayer(udg_Sorted[i]))!=PLAYER_SLOT_STATE_LEFT then
                        set udg_Experience[udg_Sorted[i]] = udg_Experience[udg_Sorted[i]] + 200
                    endif
                    set i=i+1
                endloop
            endif
            call PolledWait(8.)
            set i=1
            if udg_Mode==1 and udg_Players>5 and udg_InitialPlayers==udg_Players then
                if udg_Difficulty==5 then
                    set xp = 500
                else
                    set xp = 250
                endif
                call ALICE2Text(10.0, "Zero casualties. |cff1e90ff" + I2S(xp) + " XP|r awarded to all Marines." )
                loop
                    exitwhen i>udg_InitialPlayers
                    if GetPlayerSlotState(ConvertedPlayer(udg_Sorted[i]))!=PLAYER_SLOT_STATE_LEFT then
                        set udg_Experience[udg_Sorted[i]] = udg_Experience[udg_Sorted[i]] + xp
                    endif
                    set i=i+1
                endloop
            endif
			
            call PolledWait(20.)
			
            call EnableMOSSelection.execute()
            call EndSequenceE.execute()
        else
            call ALICE2Text(10.0, "Mission Failed. TacNukes not secured in time." )
            call EnableMOSSelection.execute()
            call PolledWait(20.)
            call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 2.0, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
            //PauseAllUnitsBJEnum
			//call PauseAllUnitsBJ(true)
			call EndSequenceF.execute()
        endif
    endfunction


    private function init takes nothing returns nothing
        call RegisterFunction("Wave18c", function Wave18c)
    endfunction

endlibrary